<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core">
<h:head>
	<title>Category</title>
	<script>
		function inputFocus(){
			document.getElementById('categoryTxt').focus();
		}
	</script>
</h:head>
<ui:composition template="template">
	<ui:define name="content">
	    <h:dataTable id="infoCategory" value="#{categoryBean.categoryList}" var="c">
			<h:column>
				<f:facet name="header">ID</f:facet>
				#{c.id}
			</h:column>
			<h:column>
				<f:facet name="header">Name</f:facet>
				#{c.name}
			</h:column>
		</h:dataTable>
		<h:form prependId="false">
			<h:panelGroup>
				<h:outputLabel for="categoryTxt" value="Category"/>
				<h:inputText id="categoryTxt" value="#{categoryBean.name}" required="true" label="name"/>
				<h:commandButton value="Save" actionListener="#{categoryBean.saveCategory}">
					<f:ajax execute="categoryTxt" render="infoCategory"/>
				</h:commandButton>
			</h:panelGroup>
			<h:message for="categoryTxt" showSummary="false" errorStyle="color:red"/>
			<script>
				inputFocus();
			</script>
		</h:form>
	</ui:define>
</ui:composition>
</html>